from collections import Counter

def intersect(nums1, nums2):
    if len(nums2) < len(nums1):
        return intersect(nums2, nums1)
    ans = []
    c = Counter(nums1)
    for n in nums2:
        if n in c:
            ans.append(n)
            c[n] -= 1
            if c[n] == 0:
                c.pop(n)
    return ans

n = int(input())
nums1 = [int(x) for x in input().split(" ")]
m = int(input())
nums2 = [int(x) for x in input().split(" ")]
print(intersect(nums1, nums2))